package com.own.component.store.core.exception;

import com.own.base.BaseResponseCode;
import com.own.component.common.exception.BusinessException;
import com.own.component.store.core.confirm.aop.ConfirmAop;
import com.own.component.store.core.confirm.model.ConfirmModel;
import com.own.component.store.core.constant.ConstantConfirmCommon;
import lombok.Getter;

/**
 * ConfirmException
 *
 * @author chenxueli
 * @date 2022-06-15 03:14:15
 */
@Getter
public class ConfirmException extends BusinessException {
    /**
     * 确认token
     */
    private String token;

    /**
     * 需要提交的key值
     */
    private String key;

    /**
     * 跳过二次确认的信息
     */
    private String skip;

    public ConfirmException() {
    }

    public ConfirmException(String code, String message) {
        super(code, message);
    }

    public ConfirmException(String code, String message, String token) {
        super(code, message);
        this.token = token;
    }

    public ConfirmException(String code, String message, String token, String key) {
        super(code, message);
        this.token = token;
        this.key = key;
    }

    public ConfirmException(ConfirmAop confirmAop, String token) {
        super(confirmAop.code(), confirmAop.message());
        this.token = token;
        this.key = confirmAop.key();
    }

    public ConfirmException(ConfirmModel model, String token) {
        super(model.getCode(), model.getMessage());
        this.token = token;
        this.skip = model.isAop() ? "" : ConstantConfirmCommon.SKIP_FIELD;
        this.key = model.getKey();
    }

    public ConfirmException(String message) {
        super(message);
    }

    public ConfirmException(BaseResponseCode responseCode) {
        super(responseCode);
    }

    public ConfirmException(BaseResponseCode responseCode, Throwable error) {
        super(responseCode, error);
    }

    public ConfirmException(BaseResponseCode responseCode, Object... args) {
        super(responseCode, args);
    }

}
